home *** CD-ROM | disk | FTP | other *** search
- /*
- * Author: Jim Arvo
- */
-
- #include "GraphicsGems.h"
-
- #define P1 (1<< 0)
- #define P2 (1<< 1)
- #define P3 (1<< 2)
- #define P4 (1<< 3)
- #define P5 (1<< 4)
- #define P6 (1<< 5)
- #define RX (1<< 6)
- #define RY (1<< 7)
- #define RZ (1<< 8)
- #define C1 (1<< 9)
- #define C2 (1<<10)
- #define C3 (1<<11)
- #define C4 (1<<12)
- #define C5 (1<<13)
- #define C6 (1<<14)
- #define C7 (1<<15)
-
- /*=========================================================================*
- * *
- * This function classifies a 3x3 matrix according to its zero structure. *
- * It returns an unsigned integer in which each bit signifies a zero *
- * structure that describes the given matrix. If all bits are zero it *
- * means the matrix is dense or does not fit any of these 16 forms. *
- * *
- * *
- * Permutations: *
- * *
- * * 0 0 0 * 0 0 0 * 0 * 0 * 0 0 0 0 * *
- * 0 * 0 0 0 * * 0 0 * 0 0 0 0 * 0 * 0 *
- * 0 0 * * 0 0 0 * 0 0 0 * 0 * 0 * 0 0 *
- * *
- * P1 P2 P3 P4 P5 P6 *
- * *
- * *
- * Simple Rotations: *
- * *
- * * 0 0 * 0 * * * 0 *
- * 0 * * 0 * 0 * * 0 *
- * 0 * * * 0 * 0 0 * *
- * *
- * RX RY RZ *
- * *
- * *
- * Permutations of the simple rotations: *
- * *
- * * 0 * 0 0 * 0 * * 0 * 0 * * 0 * 0 * 0 * * *
- * 0 * 0 * * 0 0 * * * 0 * 0 0 * * 0 * * 0 0 *
- * * 0 * * * 0 * 0 0 * 0 * * * 0 0 * 0 0 * * *
- * *
- * C1 C2 C3 C4 C5 C6 C7 *
- * *
- *=========================================================================*/
- unsigned int classify_matrix( M )
- Matrix3 M;
- {
- unsigned int form = 0xFFFF;
-
- /* Classify based on the diagonal elements. */
-
- if( M.element[0][0] != 0 ) form &= P1 | P5 | RX | RY | RZ | C1 | C5 | C6;
- if( M.element[1][1] != 0 ) form &= P1 | P6 | RX | RY | RZ | C1 | C2 | C3;
- if( M.element[2][2] != 0 ) form &= P1 | P4 | RX | RY | RZ | C1 | C4 | C7;
-
- /* Classify based on the upper triangular elements. */
-
- if( M.element[0][1] != 0 ) form &= P2 | P4 | RZ | C3 | C4 | C5 | C7;
- if( M.element[0][2] != 0 ) form &= P3 | P6 | RY | C1 | C2 | C3 | C6 | C7;
- if( M.element[1][2] != 0 ) form &= P2 | P5 | RX | C3 | C4 | C5 | C6;
-
- /* Classify based on the lower triangular elements. */
-
- if( M.element[1][0] != 0 ) form &= P3 | P4 | RZ | C2 | C4 | C6 | C7;
- if( M.element[2][0] != 0 ) form &= P2 | P6 | RY | C1 | C2 | C3 | C4 | C5;
- if( M.element[2][1] != 0 ) form &= P3 | P5 | RX | C2 | C5 | C6 | C7;
-
- return( form );
- }
-
-